package com.yincai.carefreewater.base;

import android.support.v7.widget.RecyclerView;
import android.util.SparseArray;
import android.view.View;

/**
 * Created by yeecolor on 17/3/16.
 *
 */

public class ViewHodler extends RecyclerView.ViewHolder{
    private SparseArray<View> mViews;
    public ViewHodler(View itemView) {
        super(itemView);
        this.mViews=new SparseArray<>();
    }

    public <T extends View>T getView(int viewId){
        View view=mViews.get(viewId);
        if (view==null){
            //等于空获取id添加到集合中
            view=itemView.findViewById(viewId);
            mViews.put(viewId,view);
        }
        return (T) view;
    }

    //获取单行
    public View getRootView(){

        return itemView;
    }
}
